package com.enfi.api.configuration;

import com.enfi.api.util.SecUser;
import com.enfi.api.util.UserUtils;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.domain.AuditorAware;

import java.util.Optional;

/**
 * @author wind
 * @date 2020/4/9
 */
@Configuration
public class UserAuditorAware implements AuditorAware<String> {
    @Override
    public Optional<String> getCurrentAuditor() {
        //TODO: 根据实际情况取真实用户
        SecUser secUser=UserUtils.getSecUserOrNo();
        return Optional.of(secUser==null?"":secUser.getId());
    }
}
